# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pyfilesystem2
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.4.11
pkgrel=1
pkgdesc="Python's filesystem abstraction layer (mingw-w64)"
arch=('any')
url='https://github.com/PyFilesystem/pyfilesystem2'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-appdirs"
         "${MINGW_PACKAGE_PREFIX}-python-pytz"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
# We would require "${MINGW_PACKAGE_PREFIX}-python-pyftpdlib"
#checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock"
#              "${MINGW_PACKAGE_PREFIX}-python-pyftpdlib")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/PyFilesystem/pyfilesystem2/archive/v${pkgver}.tar.gz")
sha256sums=('246424187f5a509b6dc1573c66fb203e375eab79f540dbd829dd058082be98b1')

prepare() {
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

# We would require "${MINGW_PACKAGE_PREFIX}-python-pyftpdlib"
#check() {
#  cd "${srcdir}/python-build-${CARCH}"
#  ${MINGW_PREFIX}/bin/python setup.py test
#}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
